package com.feifan.provider.mapper.redis.mapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.Set;

/**
 * @program: FinalProject
 * @author: Xiaofan
 * @createTime: 2021-08-13 14:52
 * @description: Functions of this class is
 **/
@Repository//表示当前这个类为自己手写的一个mapper
public class RedisUtilMapper {
    @Autowired
    private RedisTemplate<String,Object> redisTemplateS;

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    //先通过键找到值
    public Object get(String key){
        return key==null?null:redisTemplateS.opsForValue().get(key);
    }

    //通过值去获取其所有的键
    public Set<Object> getAllkeys(Serializable pattern){//其属性必须要是一个序列化的对象
        Set<Object> set=redisTemplate.keys(pattern);
        return set;
    }
}